﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace project.B12.application.Extensions
{
    public class RangeCheckConvert : IMultiValueConverter
    {
        public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
        {
            if (string.IsNullOrEmpty(value[0]?.ToString()))
                return false;

            double temp = double.Parse(value[0]?.ToString());
            if ( 
                double.TryParse(value[1]?.ToString(), out double upper) &&
                double.TryParse(value[2]?.ToString(), out double lower))
            {
                return temp > upper || temp < lower;
            }

            return false;
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
